Skip to content

Add test for running Log input as Filestream in Beatsreceivers#11155

Merged
belimawr merged 67 commits intoelastic:mainfrom
belimawr:log-run-as-filestream
Feb 12, 2026
Merged

Add test for running Log input as Filestream in Beatsreceivers#11155
belimawr merged 67 commits intoelastic:mainfrom
belimawr:log-run-as-filestream

Conversation

@belimawr
Copy link
Contributor

@belimawr belimawr commented Nov 12, 2025

What does this PR do?

This PR adds a test that ensures Beatsreceivers ingesting logs can:

  • Start running with a Log input configuration and ingest logs
  • Stop, then re-start with the feature flag to run Filestream input instead of the Log input
  • The Filestream input running from the Log input configuration continues ingesting the file from where the Log input had stopped.

Currently there is no way to run a Beatreceiver directly from a standalone Beats binary, hence the test in this repo.

Why is it important?

It allows us to run the Filestream input instead of the Log input for a Log input configuration

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Author's Checklist

## Disruptive User Impact

How to test this PR locally

Running integration tests

Run the test:

  1. Package the Elastic Agent for your OS
    DEV=true SNAPSHOT=true EXTERNAL=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage -v package
    
  2. Run TestFilebeatReceiverLogAsFilestream from testing/integration/ess/otel_log_as_filestream_test.go
    AGENT_VERSION="9.4.0-SNAPSHOT" SNAPSHOT=true TEST_PLATFORMS="linux/amd64" mage -v integration:single TestFilebeatReceiverLogAsFilestream
    

Manual test

Run the Elastic Agent in Otel mode setting features.log_input_run_as_filestream.enabled: true for the filebeatreceiver you want to test.

  1. Package the Elastic Agent for your OS

    DEV=true SNAPSHOT=true EXTERNAL=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage -v package
    
  2. Create a log file

    docker run --rm mingrammer/flog -n 50 > /tmp/flog.log
    
  3. Extract and run Elastic Agent in otel mode using a configuration like the one below

    ./elastic-agent otel --config otel.yml
    
    otel.yml

    receivers:
      filebeatreceiver:
        filebeat:
          inputs:
            - type: log
              id: a-unique-id
              allow_deprecated_use: true
              paths:
                - /tmp/flog.log
        output:
          otelconsumer:
        logging:
          level: debug
          selectors:
            - '*'
        features.log_input_run_as_filestream.enabled: true
    
    exporters:
      elasticsearch:
        user: elastic
        password: changeme
        endpoints:
          - https://localhost:9200
        tls:
          insecure_skip_verify: true
        logs_index: my-index
        sending_queue:
          enabled: true
          wait_for_result: true # Avoid losing data on shutdown
          block_on_overflow: true
        mapping:
          mode: none
    
    service:
      pipelines:
        logs:
          receivers: [filebeatreceiver]
          exporters: [elasticsearch]
      telemetry:
        logs:
          level: DEBUG
          encoding: json
          disable_stacktrace: true

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@mergify
Copy link
Contributor

mergify bot commented Nov 12, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b log-run-as-filestream upstream/log-run-as-filestream
git merge upstream/main
git push upstream log-run-as-filestream

@mergify
Copy link
Contributor

mergify bot commented Nov 12, 2025

This pull request does not have a backport label. Could you fix it @belimawr? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@belimawr
Copy link
Contributor Author

belimawr commented Feb 5, 2026

The tests are failing because in my last commit I modified fixture.PrepareAgentCommand to use process.Cmd which allows to gracefully shutdown the child process on Windows, however this is having unexpected effects in other tests, hence the failures.

@belimawr belimawr requested a review from Copilot February 7, 2026 02:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an integration test to validate that Beats receivers can restart using Filestream (via feature flag) while continuing ingestion from the prior Log input offset.

Changes:

  • Added a new integration test + Otel config template to validate Log → Filestream restart behavior with no duplication.
  • Refactored ES API key creation helper to be *testing.T-aware and reuse t.Context().
  • Improved infra/helpers: stricter ELASTICSEARCH_HOST validation, unzip overwrite flag, and new Fixture.Stop() support.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
testing/integration/ess/testdata/filebeat_receiver_log_as_filestream.yml Adds Otel YAML template used by the new Log→Filestream integration test
testing/integration/ess/otel_test.go Refactors ES API key helper to assert internally and use t.Context()
testing/integration/ess/otel_log_as_filestream_test.go Adds new integration test validating restart Log→Filestream continues from same offset
testing/integration/ess/beat_receivers_test.go Updates to new createESApiKey(t, client) helper signature
testing/integration/common.go Makes GetESHost() fail fast when ELASTICSEARCH_HOST is unset
pkg/testing/linux/linux.go Uses unzip -o to avoid interactive prompts on overwrite
pkg/testing/fixture.go Adds Fixture.Stop() and stores process handle for external stopping
Comments suppressed due to low confidence (1)

pkg/testing/fixture.go:1

  • This used to be Fatal but is now Error, which allows execution to continue even though the code relies on a deadline to avoid hanging. Either keep it as Fatal or return an error immediately after logging so the fixture cannot run without a deadline.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than needing more guards for the fixture addition, this looks good to me.

@swiatekm swiatekm requested a review from cmacknz February 10, 2026 17:52
@belimawr belimawr requested a review from swiatekm February 11, 2026 20:29
swiatekm
swiatekm previously approved these changes Feb 12, 2026
Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
@swiatekm swiatekm self-requested a review February 12, 2026 16:03
Copy link
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and thanks for adjusting the other tests!

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @belimawr

@belimawr belimawr merged commit 509bc71 into elastic:main Feb 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants